#ifndef STRVEC_H
#define STRVEC_H
#include <iostream>
#include <string>
#include <memory>

using namespace std;

class StrVec{
public:
	StrVec() : elements(nullptr), first_free(nullptr), cap(nullptr){ }
    StrVec(const initializer_list<string>&);
	explicit StrVec(const StrVec&);
	StrVec& operator=(const StrVec&);
	~StrVec();
	void push_back(const string&);
	size_t size() const{return (first_free - elements);}
	size_t capacity() const{return (cap - elements);}
	string* begin() const{return elements;}
	string* end() const{return first_free;}
    void reserve(size_t new_cap);
    void resize(size_t count);
    void resize(size_t count, const std::string& value);
private:
	string *elements; 
	string *first_free;
	string *cap;
	
	static allocator<string> alloc;
	pair<string*, string*> alloc_n_copy(const string*, const string*);
	void free();
	void reallocate();
	void chk_n_alloc(){
		if(size() == capacity())
			reallocate();
	}
};

#endif
